#!/bin/bash

ELEMENT_NUM=100
COUNT=10000
STEP=50

make brown2d

./brown2d $ELEMENT_NUM $COUNT $STEP

i=1
for step in $( seq 0 $STEP $COUNT )
do

  echo set datafile separator \",\"              >  .tmp
  echo set xrange[-100:100]                      >> .tmp
  echo set yrange[-100:100]                      >> .tmp
  echo set term png                              >> .tmp
  echo set output \"$( printf %06d $i ).png\"    >> .tmp
  echo plot \"$( printf %06d $step ).csv\"       >> .tmp
  echo set output                                >> .tmp
  gnuplot .tmp
  echo [log] $step step done.

  i=$(( i + 1 ))
  rm -f .tmp
  rm -f $( printf %06d $step ).csv

done

convert *.png brown2d.gif
echo [log] brown2d.gif was generated.

ffmpeg -r 6 -i %06d.png brown2d.flv
echo [log] brown2d.flv was generated.

rm *.png

